package com.bbex.constant;

/**
 * project :bbex
 *
 * @author xiaoyu
 * @version 1.0
 * @date 2018 /4/22 下午3:19
 * @since JDK 1.8
 */
public final class RedisKeyConstant {

    private static final String TASK_STAT_PRE_FIX = "task:trade-date:";

    private static final String USER_COIN_VOLUME = "user:coin:volume:";

    public static final String TRADE_STATISTIC_TOPIC = "topic.trade.statistic";

    public static final String TASK_KLINE_STAT_PRE_FIX = "task:kline:stat:";

    private static final String REDIS_COIN_SYMBOL = "coin:price:%s";

    /**
     * Build user coin volume key string.
     *
     * @param userId the user id
     * @return the string
     */
    public static String buildUserCoinVolumeKey(String userId) {
        return String.join("", USER_COIN_VOLUME, userId);
    }

    /**
     * Build task stat trade to day string.
     *
     * @param coinMain  the coin main
     * @param coinOther the coin other
     * @return the string
     */
    public static String buildTaskStatTradeToDay(String coinMain, String coinOther) {
        return String.join("", TASK_STAT_PRE_FIX, coinMain + "_" + coinOther);
    }

    /**
     * Build task kline stat key string.
     *
     * @param coinMain  the coin main
     * @param coinOther the coin other
     * @param interval  the interval
     * @return the string
     */
    public static String buildTaskKlineStatKey(String coinMain, String coinOther, String interval) {
        return TASK_KLINE_STAT_PRE_FIX + coinMain + "_" + coinOther + ":" + interval;
    }

    /**
     * Build usdt price key string.
     *
     * @return the string
     */
    public static String buildUsdtPriceKey() {
        return String.format(REDIS_COIN_SYMBOL, "USDT");
    }

}
